<script type="text/javascript" src="<?php echo base_url() . SKINSPATH; ?>js/jquery.timepicker/jquery-ui-timepicker-addon.js"></script>
<link rel="stylesheet" href="<?php echo base_url() . SKINSPATH; ?>js/jquery.timepicker/jquery-ui-timepicker-addon.css" type="text/css"/>
<div class="content-box">
    <div class="box-header clear">
        <h2><?php echo lang('pg_add_termination') ?></h2>
    </div>
    <div class="box-body clear">
        <?php echo validation_errors(); ?>
        <?php echo form_open(base_url().'termination/add'); ?>
        <div class="form-field clear">
            <label class="form-label fl-space2"><?php echo lang('lbl_category') ?> :</label>
            <select name="category_id" id="category_id" onchange="getProduct();">
            	<option value=""><?php echo lang('lbl_select_category') ?></option>
            <?php 
            foreach($categorys as $item){
				echo "<option value='".$item->id."'>".$item->category_name."</option>";
			}
            ?>
            </select>
        </div>
        <div class="form-field clear">
            <label class="form-label fl-space2"><?php echo lang('lbl_provider') ?> :</label>
            <select name="provider_id" id="provider_id" onchange="getProduct();">
            	<option value=""><?php echo lang('lbl_select_provider') ?></option>
            <?php 
            foreach($providers as $item){
				echo "<option value='".$item->id."'>".$item->provider_name."</option>";
			}
            ?>
            </select>
        </div>
        <div class="form-field clear">
            <label class="form-label fl-space2"><?php echo lang('lbl_product') ?> :</label>
            <select name="product_id" id="product_id">
            	<option value=""><?php echo lang('lbl_select_product') ?></option>
            </select>
        </div>
        <div class="form-field clear">
            <label class="form-label fl-space2"><?php echo lang('lbl_member') ?> :</label>
            <select name="member_id" id="member_id">
            	<option value=""><?php echo lang('lbl_select_member') ?></option>
            <?php 
            foreach($members as $item){
				echo "<option value='".$item->id."'>".$item->first_name." ".$item->last_name."</option>";
			}
            ?>
            </select>
        </div>
        <div class="form-field clear">
            <label class="form-label fl-space2"><?php echo lang('lbl_contract') ?> :</label>
            <input type="text" value="<?php echo set_value('contract_number'); ?>" name="contract_number" id="contract_number" class="text" maxlength="10" />
        </div>
        <div class="form-field clear">
            <label class="form-label fl-space2"><?php echo lang('lbl_status') ?> :</label>
            <?php echo form_dropdown('status', $status, '0'); ?>
        </div>
        <div class="form_submit">
            <input type="submit" class="submit" value="<?php echo lang('btn_save') ?>" id="save" name="save">
            <input onclick='location.href = "<?php echo base_url() ?>termination"' type="button" class="submit" value="<?php echo lang('btn_cancel') ?>" name="cancel">
        </div>
        <?php echo form_close(); ?>
    </div>
</div>
<script type="text/javascript">
    function getContract(){
		if($('#member_id').val() ){
			$.ajax({
	            type: "POST",
	            url: "<?php echo base_url() ?>contract/getbymember",
	            data: "member_id=" + $('#member_id').val(),
	            success: function(result) {
	            	$('#contract_id').html( result );
	            }
	        })
		}
    }
    function getProduct(){
		if($('#category_id').val() && $('#provider_id').val()){
			$.ajax({
	            type: "POST",
	            url: "<?php echo base_url() ?>contract/getproduct",
	            data: "category_id=" + $('#category_id').val() + "&provider_id=" + $('#provider_id').val(),
	            success: function(result) {
	            	$('#product_id').html( result );
	            }
	        })
		}
    }
</script>